home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / idstack.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  2.5 KB  |  66 lines

  1. /* Copyright (C) 1998, 1999 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: idstack.h,v 1.2 2000/09/19 19:00:43 lpd Exp $ */
  20. /* Generic dictionary stack API */
  21.  
  22. #ifndef idstack_INCLUDED
  23. #  define idstack_INCLUDED
  24.  
  25. #include "iddstack.h"
  26. #include "idsdata.h"
  27. #include "istack.h"
  28.  
  29. /* Define the type of pointers into the dictionary stack. */
  30. typedef s_ptr ds_ptr;
  31. typedef const_s_ptr const_ds_ptr;
  32.  
  33. /* Clean up a dictionary stack after a garbage collection. */
  34. void dstack_gc_cleanup(P1(dict_stack_t *));
  35.  
  36. /*
  37.  * Define a special fast entry for name lookup on a dictionary stack.
  38.  * The key is known to be a name; search the entire dict stack.
  39.  * Return the pointer to the value slot.
  40.  * If the name isn't found, just return 0.
  41.  */
  42. ref *dstack_find_name_by_index(P2(dict_stack_t *, uint));
  43.  
  44. /*
  45.  * Define an extra-fast macro for name lookup, optimized for
  46.  * a single-probe lookup in the top dictionary on the stack.
  47.  * Amazingly enough, this seems to hit over 90% of the time
  48.  * (aside from operators, of course, which are handled either with
  49.  * the special cache pointer or with 'bind').
  50.  */
  51. #define dstack_find_name_by_index_inline(pds,nidx,htemp)\
  52.   ((pds)->top_keys[htemp = dict_hash_mod_inline(dict_name_index_hash(nidx),\
  53.      (pds)->top_npairs) + 1] == pt_tag(pt_literal_name) + (nidx) ?\
  54.    (pds)->top_values + htemp : dstack_find_name_by_index(pds, nidx))
  55. /*
  56.  * Define a similar macro that only checks the top dictionary on the stack.
  57.  */
  58. #define if_dstack_find_name_by_index_top(pds,nidx,htemp,pvslot)\
  59.   if ( (((pds)->top_keys[htemp = dict_hash_mod_inline(dict_name_index_hash(nidx),\
  60.      (pds)->top_npairs) + 1] == pt_tag(pt_literal_name) + (nidx)) ?\
  61.     ((pvslot) = (pds)->top_values + (htemp), 1) :\
  62.     0)\
  63.      )
  64.  
  65. #endif /* idstack_INCLUDED */
  66.